//
//  BaseViewController.h
//  TuanLife
//
//  Created by 伏圣文 on 2017/12/23.
//  Copyright © 2017年 HuiNaMac. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <MJRefresh/MJRefresh.h>
#import <MJRefresh/MJRefreshFooter.h>
#import <ReactiveObjC/ReactiveObjC.h>
 
#import <JPush/JPUSHService.h>
#import <IQKeyboardManager/IQKeyboardManager.h> 
#import <AFNetworking/AFNetworking.h>
#import <AVFoundation/AVCaptureDevice.h>
#import <AVFoundation/AVMediaFormat.h>
 
 
NS_ASSUME_NONNULL_BEGIN

typedef void(^XCRereshHeaderBlock)(void);
typedef void(^XCRereshFooterBlock)(void);
typedef void(^XCLeftBarItemActionBlock)(void);
typedef void(^XCRightBarItemActionBlock)(void);

 
typedef NS_ENUM(NSUInteger, XCBarItemType) {
    OnlyHaveImage,
    OnlyHaveTitle,
    HaveImageAndImage,
};

@interface BaseViewController : UIViewController

@property (nonatomic, copy) XCRereshHeaderBlock refreshHeaderBlock;
@property (nonatomic, copy) XCRereshFooterBlock refreshFooterBlock;
@property (nonatomic, copy) XCLeftBarItemActionBlock leftBarItemActionBlock;
@property (nonatomic, copy) XCRightBarItemActionBlock rightBarItemActionBlock;
 
@property(nonatomic,assign) NSInteger is_location;
@property(nonatomic,assign) NSInteger is_location_result;
@property(nonatomic,strong) NSString *aoi_name;
@property(nonatomic,strong) NSString *poi_name;
@property(nonatomic,strong) NSString *location_name;
@property (nonatomic,strong)UIImageView *topBackImageView;
@property(nonatomic,strong) NSString *provinceStr;
@property(nonatomic,strong) NSString *cityStr;
@property(nonatomic,strong) NSString *countyStr; 

/**
 *  MJ头部刷新
 *
 *  @param block 刷新完成回调
 *
 *  @return 返回头部刷新的实例
 */
- (MJRefreshHeader*)headerRefreshBlock:(XCRereshHeaderBlock)block;
- (MJRefreshHeader*)headerGifRefreshBlock:(XCRereshHeaderBlock)block;

/**
 *  MJ尾部上拉刷新（自动）
 *
 *  @param block 刷新完成回调
 *
 *  @return 返回尾部自动刷新的实例
 */
- (MJRefreshAutoFooter*)autoFooterRefreshBlock:(XCRereshFooterBlock)block;
- (MJRefreshAutoFooter*)autoFooterGifRefreshBlock:(XCRereshFooterBlock)block;
/**
 *  MJ尾部上拉刷新（回弹）
 *
 *  @param block 刷新完成回调
 *
 *  @return 返回尾部回弹刷新的实例
 */
- (MJRefreshBackFooter*)backFooterRefreshBlock:(XCRereshFooterBlock)block;
- (MJRefreshBackFooter*)backFooterGifRefreshBlock:(XCRereshFooterBlock)block;
/**
 *  导航栏左Item
 *
 *  @param type      item类型
 *  @param title     标题
 *  @param font      标题大小
 *  @param image 图片
 *  @param block     响应回调
 */
- (void)setNavigationLeftBarItemType:(XCBarItemType)type title:(NSString *)title titleFont:(CGFloat)font titleColor:(UIColor *)color  image:(UIImage*)image responderBlock:(void(^)(void)) block;

/**
 *  导航栏右Item
 *
 *  @param type      item类型
 *  @param title     标题
 *  @param font      标题大小
 *  @param image 图片
 *  @param block     响应回调
 */
- (void)setNavigationRightBarItemType:(XCBarItemType)type title:(NSString *)title titleFont:(CGFloat)font titleColor:(UIColor *)color image:(UIImage *)image responderBlock:(void (^)(void))block;

/**
 *  实例化控制器
 *
 *  @param storyboardName sb名称
 *
 *  @return viewcontroller
 */
- (nullable __kindof instancetype)instantiateInitialViewControllerWithStoryboardName:(nonnull NSString *)storyboardName;

/**
 *  根据identifier实例化控制器
 *
 *  @param storyboardName sb名称
 *  @param identifier sb的ID
 *
 *  @return viewcontroller
 */
- (nullable __kindof instancetype)instantiateViewControllerWithStoryboardName:(nonnull NSString *)storyboardName identifier:(nonnull NSString *)identifier;

/**
 *  获取指定控制器
 *
 *  @param currentViewControllerName 指定控制器名称
 *
 *  @return 指定控制器
 */
- (BaseViewController *)getTargetViewController:(NSString*)currentViewControllerName;

/**
 绘制导航栏背景图
 
 @param frame 大小
 @param alphe 透明度
 @param color 颜色
 @return uiimage
 */
- (UIImage *)imageWithFrame:(CGRect)frame alphe:(CGFloat)alphe andColor:(UIColor*)color;

@end

@interface BaseViewController(Fast)

/**
 设置导航栏原始状态
 */
- (void)setNavigationOrigin;

/**
 设置导航栏透明 字体白色
 */
- (void)setNavigationClear;
- (void)setNavigationSignClear;
/**
 *  @author liuxiaochun, 16-11-12
 *
 *  从StoryBoard文件快速获取UIViewController（stroryboard名字可任意，UIViewController的identifier和类名必须一致）
 *
 *  @return ViewController
 *
 *  @since 1.1
 */
+ (nonnull instancetype)fastInstantiateViewController;

/**
 *  @author liuxiaochun, 16-11-12
 *
 *  导航视图控制器push
 *
 *  @param viewController 目标视图控制器
 *
 *  @since 1.0
 */
- (void)pushViewController:(nonnull UIViewController *)viewController;

/**
 *  @author liuxiaochun, 16-11-12
 *
 *  导航视图控制器pop
 *
 *  @since 1.0
 */
- (void)pop;

/**
 *  @author liuxiaochun, 16-11-12
 *
 *  导航视图控制器pop到root
 *
 *  @since 1.0
 */
- (void)popToRoot;

/**
 *  @author liuxiaochun, 16-11-12
 *
 *  导航视图控制器pop到指定viewController
 *
 *  @param viewController 目标视图控制器
 *
 *  @return 被pop的视图控制器组
 *
 *  @since 1.0
 */
- (nullable NSArray<__kindof BaseViewController *> *)popToViewController:(nonnull UIViewController *)viewController;

@end

@interface BaseViewController (Loader)


/**
 *  显示模态载入器
 */
- (void)showLoader;

/**
 *  隐藏模态载入器
 */
- (void)hideLoader;

/**
 *  聪慧的载入器（根据state的值确定是显示还是隐藏）
 *
 *  @param state 是否显示载入器
 */
- (void)cleverLoader:(BOOL)state;

@end

@interface BaseViewController (MJGifRefresh)

@end

@interface BaseViewController (Navigation)

@end

@interface BaseViewController (UMeng)
-(void)configUMengShare;
@end

@interface BaseViewController (JPush)

-(void)configJpush:(NSString *)jpush_username;

@end

@interface BaseViewController (Alert)

/**
 系统弹窗双选项
 
 @param title 标题
 @param message 文本内容
 @param ok 确定
 @param cancle 取消
 @param OK 确定按钮回调
 */
- (void)alertTitle:(NSString *)title andMessage:(NSString *)message andOK:(NSString*)ok andCancle:(NSString*)cancle andBlock:(void (^)(UIAlertAction *action))OK;

/**
 系统弹窗单选项
 
 @param title 标题
 @param message 具体信息
 @param handler 回调
 */
- (void)alertTitle:(NSString*)title andMessage:(NSString*)message andCancleBlock:(void (^ __nullable)(UIAlertAction *action))handler;

/**
 系统弹窗双选回调
 
 @param title 标题
 @param message 内容
 @param ok ok
 @param cancle cancle
 @param OK ok回调
 @param cancleBlock 取消回调
 */
- (void)alertTitle:(NSString *)title andMessage:(NSString *)message andOK:(NSString*)ok andCancle:(NSString*)cancle andBlock:(void (^)(UIAlertAction *action))OK andCancleBlock:(void (^)(UIAlertAction *action))cancleBlock;

@end

@interface BaseViewController (Network)

/**
 实时检测网络状态
 
 @param block 回调
 */
- (void)networkStatus:(void(^)(NSInteger status))block;

@end

@interface BaseViewController (Login)

/**
 登陆拦截
 
 @return 是否拦截
 */
- (BOOL)loginAlert;

@end

@interface BaseViewController (CallCustomer)

- (void)callCustomer:(void (^ __nullable)(UIAlertAction *action))handler andOK:(void (^ __nullable)(UIAlertAction *action))okHandler;
- (void)callCustomer:(NSString *)phone addCall:(void (^ __nullable)(UIAlertAction *action))handler andOK:(void (^ __nullable)(UIAlertAction *action))okHandler;
@end

@interface BaseViewController (Token)
- (void)getToken:(void(^)(NSString *token))block;
@end

@interface BaseViewController (versions)

- (void)getNewVersions:(void(^)(NSString *neetUpadte))block;

@end

 
@interface BaseViewController (notifCode)

-(void)configUMengShare:(NSInteger)code;
@end


@interface BaseViewController (checkVideo)

- (void) checkVideoStatus:(void(^)(NSInteger status,NSString *message))block;
@end
NS_ASSUME_NONNULL_END
